﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EventSetParent : MonoBehaviour
{
    public RectTransform parentTsf;
    public bool setPosition;        // 设置parent后是否设置位置
    public void SetParent(RectTransform targetTsf)
    {
        if (targetTsf != null)
        {
            targetTsf.SetParent(parentTsf);
            if (setPosition)
                targetTsf.anchoredPosition = Vector2.zero;
        }
    }

    public void SetParentNull(RectTransform targetTsf)
    {
        if (targetTsf != null)
            targetTsf.parent = null;
    }
}
